package com.anti.modular.bus.basicinformation.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.basicinformation.param.BasicInformationParam;
import com.anti.modular.bus.basicinformation.service.BasicInformationService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 户型控制器
 *
 * @author anti
 * @date 2021-04-07 19:24:48
 */
@RestController
@RequestMapping("basicInformation")
public class BasicInformationController {

    @Resource
    private BasicInformationService basicInformationService;

    /**
     * 查询户型
     *
     * @author anti
     * @date 2021-04-07 19:24:48
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, BasicInformationParam basicInformationParam) {
        return Result.data(basicInformationService.page(pageParam,basicInformationParam));
    }

    /**
     * 添加户型
     *
     * @author anti
     * @date 2021-04-07 19:24:48
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "户型_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(BasicInformationParam.add.class) BasicInformationParam basicInformationParam) {
            basicInformationService.add(basicInformationParam);
        return Result.success("新增成功");
    }

    /**
     * 删除户型
     *
     * @author anti
     * @date 2021-04-07 19:24:48
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "户型_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(BasicInformationParam.delete.class) BasicInformationParam basicInformationParam) {
            basicInformationService.delete(basicInformationParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑户型
     *
     * @author anti
     * @date 2021-04-07 19:24:48
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "户型_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(BasicInformationParam.edit.class) BasicInformationParam basicInformationParam) {
            basicInformationService.edit(basicInformationParam);
        return Result.success("修改成功");
    }

    /**
     * 查看户型
     *
     * @author anti
     * @date 2021-04-07 19:24:48
     */
    @GetMapping("detail")
    public Result detail(@Validated(BasicInformationParam.detail.class) BasicInformationParam basicInformationParam) {
        return Result.data(basicInformationService.detail(basicInformationParam));
    }

    /**
     * 户型列表
     *
     * @author anti
     * @date 2021-04-07 19:24:48
     */
    @GetMapping("list")
    public Result list() {
        return Result.data(basicInformationService.list());
    }

}
